package com.meiborte.controller;

import com.meiborte.mapper.ItemMapper;
import com.meiborte.pojo.Item;
import com.meiborte.service.ItemService;
import jakarta.annotation.Resource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
    @RequestMapping("Item")
    public class ItemController {

        @Resource
        ItemService service;
    @Autowired
    private ItemMapper itemMapper;


    @GetMapping("selectById")
        public Item selectById(@RequestParam Integer id) {
            return service.selectById(id);
        }

        @GetMapping("selectAll")
        public List<Item> selectAll() {
            return service.selectAll();
        }
        @GetMapping("selectByType")
        public List<Item> selectByType(@RequestParam String type) {
            return service.selectByType(type);
        }
        @GetMapping("deleteById")
        public String deleteById(@RequestParam Integer id) {
            service.deleteById(id);
            return "";
        }
    @PostMapping("insert")
    public Item insert(@RequestBody Item item) {
        return service.insert(item);
    }
    @PostMapping("updateById")
    public Item updateById(@RequestBody Item item) {
        return service.updateById(item); // Return the updated item
    }
}

